/*
 * @lc app=leetcode.cn id=435 lang=typescript
 *
 * [435] 无重叠区间
 */

// @lc code=start
function eraseOverlapIntervals(intervals: number[][]): number {
    let count = 0;
    if (intervals.length === 0) {
        return count;
    }
    intervals.sort((a, b) => a[1] - b[1])
    let max = intervals[0][1];
    count++;
    for (let i = 1; i < intervals.length; i++) {

        if (intervals[i][0] >= max) {
            ++count;
            max = intervals[i][1];
        }
    }
    return intervals.length - count;
};

// eraseOverlapIntervals([[-3035, 30075], [1937, 6906], [11834, 20971], [44578, 45600], [28565, 37578], [19621, 34415], [32985, 36313], [-8144, 1080], [-15279, 21851], [-27140, -14703], [-12098, 16264], [-36057, -16287], [47939, 48626], [-15129, -5773], [10508, 46685], [-35323, -26257]])
// @lc code=end

